package 平时作业.王宏宇.view;
import java.util.Scanner;

public class LoginMenu {
    public void printLoginMenu(){
        int count = 0;
        Scanner sc = new Scanner(System.in);
        do {
            System.out.println("\t\t\t系统登录");
            System.out.println("------------------");
            System.out.println("请输入用户名：");
            String uname = sc.next();
            System.out.println("请输入密码：");
            String upwd = sc.next();
            //硬编码编写，字符串比较用equals
            if (uname.equals("admin") && upwd.equals("123456")) {
                count = 0;
                System.out.println("登录成功。");
                break;
            } else {
                count++;
                System.out.println("登录失败！用户名或密码有误！");
                if(count<=2)
                    System.out.println("当前已失败"+count+"次"+"剩余登陆次数："+(3-count)+"次！");
                else{
                    System.out.println("非法用户，即将退出系统!");
                }
            }
        }while (count<3);
    }
}
